package com.itheima01;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;

public class Test06 {
    //反射越过泛型编译期检查  泛型是编译期代码语法检查机制，只存在于编译期
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {

        ArrayList<Integer> list = new ArrayList<>();

        Method add = list.getClass().getDeclaredMethod("add", Object.class);

        add.invoke(list, "100");
        add.invoke(list, "100");
        add.invoke(list, new Car());
        add.invoke(list, 100);


//        System.out.println(list);
        for (Object obj : list) {
            System.out.println(obj);
        }
    }
}
